package com.yc.chaoshi.cs_order.controller;


import com.yc.chaoshi.cs_order.DTO.GoodsAndAdress;
import com.yc.chaoshi.cs_order.DTO.OrderAllDTO;
import com.yc.chaoshi.cs_order.DTO.OrderGoodsDTO;
import com.yc.chaoshi.cs_order.service.impl.OmsOrderServiceImpl;

import com.yc.chaoshi.entity.OmsOrder;
import com.yc.chaoshi.entity.PmsGoods;
import com.yc.common.api.CommonResult;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xz
 * @since 2022-08-04
 */
@RestController
@RequestMapping("/chaoshi/omsOrder")
public class OmsOrderController {
   @Resource
   OmsOrderServiceImpl omsOrderService;
   @GetMapping("list/{uid}")
    public CommonResult list(@RequestParam(value = "orderid",defaultValue = "") String orderid,@PathVariable Integer uid){
       System.out.println(orderid);
       List<OrderGoodsDTO> orderGoodsDTO=omsOrderService.listAndGoods(uid,orderid);
       return CommonResult.success(orderGoodsDTO);
   }
   @GetMapping("listbyid/{uid}")
   public CommonResult listbyId(@RequestParam(value = "orderid",defaultValue = "") String orderid,@PathVariable Integer uid){
      GoodsAndAdress orderGoodsDTO=omsOrderService.listbyId(uid,orderid);
      return CommonResult.success(orderGoodsDTO);
   }
   @PostMapping("ByIdsOrder")
   @ResponseBody
   public CommonResult ByIdsOrder(@RequestBody List<Integer> goodsid){
      List<PmsGoods> goods=omsOrderService.ByIdsOrder(goodsid);
         return CommonResult.success(goods);
   }
   @PostMapping("addorder")
   @ResponseBody
   public CommonResult addorder(@RequestBody OrderAllDTO orderAllDTO){
       Integer id=omsOrderService.addorder(orderAllDTO);
      return CommonResult.success(id);
   }
   @PostMapping("byid/{uid}")
   public CommonResult ById(@RequestParam(value = "orderid",defaultValue = "") String orderid,@PathVariable Integer uid){
      OmsOrder omsOrder=omsOrderService.ById(uid,orderid);
      return CommonResult.success(omsOrder);
   }
}

